package com.yzc.controller;

import com.yzc.model.DTO.AttractionOrderDetail;
import com.yzc.model.vo.page.PageResult;
import com.yzc.model.vo.ticket_order.AttractionOrderVO;
import com.yzc.result.Result;
import com.yzc.service.TicketAttractionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ticketOrder/attractionOrder")
public class TicketAttractionOrderController {

    @Autowired
    private TicketAttractionOrderService ticketOrderService;

    @GetMapping("/list/{userId}/{pageNo}/{pageSize}")
    public Result<PageResult<AttractionOrderVO>> listOrders(
            @PathVariable("userId") Long userId,
            @PathVariable("pageNo") Integer pageNo,
            @PathVariable("pageSize") Integer pageSize) {
        PageResult<AttractionOrderVO> pageResult = ticketOrderService.listOrders(userId, pageNo, pageSize);
        return Result.success(pageResult);

    }

    @PostMapping("/create")
    public Result<Void> createOrder(@RequestBody AttractionOrderDetail attraction) {
        ticketOrderService.createTicketOrder(attraction);
        return Result.success();
    }


    @PostMapping("/pay")
    public Result<String> payOrder(@RequestParam("orderId") Long orderId, @RequestParam("paymentMethod") String paymentMethod) {
        return ticketOrderService.payOrder(orderId, paymentMethod);
    }

}